{% extends "../layouts/admin.html" %} {% block content %}
<header class="header navbar bg-white shadow">
	<div class="btn-group tool-button">
		<a class="btn btn-primary navbar-btn" href="/system/asset/index" data-pjax id="goback"><i class="ti-angle-left"></i> 返回</a>
	</div>
</header>

<div class="content-wrap">
	<div class="wrapper" style="min-height:500px;">
		<section class="panel panel-form">
			<form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate action="/system/asset/edit" method="post">
				<input id="id" name="id" value="{{asset.id}}" type="hidden">

				<div class="row mb10">
					<div class="col-lg-12">
						<div class="form-group">
							<label for="amount" class="col-sm-2 control-label">金钱</label>

							<div class="col-sm-8">
								<input type="text" id="amount" class="form-control" name="amount" value="{{asset.amount}}" data-parsley-required="true" data-parsley-pattern="([1-9](\d+)?(\.\d{1,2})?)|(^(0){1})|(^\d\.\d{1,2}?)" placeholder="金钱">
							</div>
						</div>
						<div class="form-group">
							<label for="score" class="col-sm-2 control-label">积分</label>

							<div class="col-sm-8">
								<input type="text" id="score" value="{{asset.score}}" class="form-control" name="score" data-parsley-required="true" data-parsley-pattern="[1-9](\d+)?" placeholder="积分">
							</div>
						</div>
						<div class="form-group">
							<label for="rebate" class="col-sm-2 control-label">预估分红</label>

							<div class="col-sm-8">
								<input type="text" id="rebate" value="{{asset.rebate}}" class="form-control" name="rebate" data-parsley-required="true" data-parsley-pattern="([1-9](\d+)?(\.\d{1,2})?)|(^(0){1})|(^\d\.\d{1,2}?)" placeholder="预估分红">
							</div>
						</div>
						<div class="form-group">
        <label for="level" class="col-sm-2 control-label">用户级别</label>
        <div class="col-sm-8">
        <select name="level" id="level" class="form-control">
        	<option value=""  selected>级别</option>
									{% for item in userLevels %} 
									<option value="{{item.id}}" {% if item.id == asset.level%}selected{% endif %}>{{item.name}}</option>
									{% endfor %}
        </select>
        </div>
        
      </div>
						
					</div>
				</div>
				<div class="col-lg-3"></div>
				<div class="col-lg-6">
					<div class="form-group text-center">
						<label></label>

						<div>
							<button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
						</div>
					</div>
				</div>
			</form>
		</section>

	</div>
</div>
<script language="JavaScript">
	$(document).ready(function() {
		
		$('#addForm').ajaxForm({
			dataType: 'json',
			beforeSubmit: function(arr, form, options) {
				form.find("button:submit").button("loading");
			},
			success: function(data, statusText, xhr, form) {
				if(data.errno == 0) {
					Toast.success(data.data);
					setTimeout(function() {
						$("#goback").trigger("click");
					}, 1000);
				} else {
					Toast.error(data.errmsg);
				}
				form.find("button:submit").button("reset");
			}
		});
	});
</script>
{% endblock %}